import Quick from ".";
import { WeaSelect, WeaLocaleProvider } from 'ecCom';
const { getLabel } = WeaLocaleProvider;

export default class Main extends Quick {
    state = {
        value: ''
    }
    getComponent = () => {
        const { value } = this.state;
        const { designerStore } = this.props;
        const detailTable = [{key:'all',showname:'all'}];
        designerStore.workbook.sheets.forEach(sheet => {
            const name = sheet.name();
            sheet.tables.all().forEach(table => {
                const tableName = `${name}.${table.name()}`;
                if(table.name()&&table.name().indexOf('custom')==-1){
                    detailTable.push({
                        key: tableName,
                        showname: tableName
                    })
                }
            })
        })
        return (
            <div>
                <WeaSelect ecId={`${this && this.props && this.props.ecId || ''}_WeaSelect@dnzgv7`}
                    style={{ minWidth: 200 }}
                    options={detailTable}
                    value={value}
                    showSearch={true}
                    optionFilterProp="children"
                    onChange={v => this.setState({ value: v })}
                    placeholder={getLabel('511722','请选择明细表')}
                />
            </div>
        )
    }
    getTitle = () => {
        return 'excel.hideInsertTopRow';
    }
    getScript = () => {
        return `excel.hideInsertTopRow('${this.state.value}');`
    }
}